package lore.miniwechat.web;

import lore.miniwechat.dto.BaseResponse;
import lore.miniwechat.entity.Admin;
import lore.miniwechat.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class AdminController {

    @Autowired
    AdminService service;

    //查询管理员
    @GetMapping("/admin")
    public List<Admin> getAdmins(){
        return service.getAdmins();
    }

    //添加管理员
    @PostMapping("/insert")
    public BaseResponse addAdmin(@RequestBody Admin admin){

        service.insert(admin);
        return BaseResponse.success();
    }


    //删除管理员（标记删除，并不是真正意义上的删除）
    @DeleteMapping
    public BaseResponse deleteAdmin(@PathVariable String id){
        service.deleteAdmin(id);
        return BaseResponse.success();
    }

    //修改管理员信息
    @PutMapping
    public BaseResponse updateAdmin(@PathVariable String id){
        service.update(id);
        return BaseResponse.success();
    }

}
